<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 * @author   howe <howe1995@163.com>
 */
use Hyperf\Database\Migrations\Migration;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Schema\Schema;

return new class() extends Migration {
    // php artisan make:migration create_users_table --create=users
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('wechat')->default('')->comment('微信号')->unique('uk_wechat');
            $table->string('mobile')->default('')->comment('手机号')->unique('uk_mobile');
            $table->string('password')->default('')->comment('密码');
            $table->string('salt')->default('')->comment('密码盐');
            $table->string('token', 1024)->default('')->comment('token');
            $table->integer('token_expire_in')->default(0)->comment('token过期时间');
            $table->string('nickname')->default('')->comment('昵称');
            $table->string('avatar')->default('')->comment('头像');
            $table->string('sign')->default('')->comment('签名');
            $table->enum('gender', ['male', 'female', 'unknown'])->default('unknown')->comment('性别');
            $table->integer('bg_file_id')->default(0)->comment('背景图文件ID');
            $table->string('bg_file_path')->default('')->comment('背景图路径');
            $table->integer('moment_bg_file_id')->default(0)->comment('朋友圈背景图文件ID');
            $table->string('moment_bg_file_path')->default('')->comment('朋友圈背景图路径');
            $table->enum('status', ['normal', 'ban'])->default('normal')->comment('状态');
            $table->json('unread')->nullable()->comment('未读消息');
            $table->json('setting')->nullable()->comment('设置');
            $table->integer('money')->default(0)->comment('余额');
            $table->timestamp('created_at')->useCurrent()->comment('创建时间');
            $table->timestamp('updated_at')->useCurrent()->comment('更新时间');
            $table->comment('用户表');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('users');
    }
};
